package com.board.util;

public class Result<T> {
    private Integer code;//业务状态码
    private String message;//业务描述信息
    private Boolean flag;
    private T data;//返回给前端的数据

    public static Result success(String message, Object data){
        Result r = new Result();
        r.setCode(200);
        r.setFlag(true);
        r.setMessage(message);
        r.setData(data);
        return r;
    }

    public static Result fail(Integer code, String message){
        Result r = new Result();
        r.setCode(code);
        r.setFlag(false);
        r.setMessage(message);
        return r;
    }


    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Boolean getFlag() {
        return flag;
    }

    public void setFlag(Boolean flag) {
        this.flag = flag;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
